home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 52 / Mac Magazin and MacEasy Magazine CD - Issue 52.iso / Updates / Stata 5.0 Ado-files / ado.sea / newado / matrix.hlp < prev    next >
Text File  |  1998-11-22  |  8KB  |  280 lines

  1. .-
  2. help for ^matrix^                                           (manual:  ^[R] matrix^)
  3. .-
  4.  
  5. Summary of matrix commands
  6. --------------------------
  7.  
  8. Comments are provided below under the headings
  9.  
  10.      1.  Inputting matrices by hand
  11.      2.  Obtaining copies of system matrices
  12.      3.  Accumulating cross-product matrices
  13.      4.  Matrix operators
  14.      5.  Matrix functions
  15.      6.  Eigenvalues and eigenvectors of symmetric matrices
  16.      7.  Singular value decomposition
  17.      8.  Matrix functions returning scalars
  18.      9.  Macro extended functions regarding matrices
  19.     10.  Submatrix extraction
  20.     11.  Submatrix placement
  21.     12.  Generating scores from coefficient vectors
  22.     13.  Setting row and column names
  23.     14.  Posting and redisplaying estimation results
  24.     15.  Constraint processing
  25.     16.  Matrix utilities
  26.  
  27. In the syntax diagrams, capital letters A, B, ..., Z stand for matrix names.
  28. Full details can be found in ^[R] matrix^.
  29.  
  30.  
  31. 1.  Inputting matrices by hand (see ^[R] matrix^ and ^[R] matrix define^)
  32. ---------------------------------------------------------------------
  33.  
  34.     ^mat^rix A ^= (^#[^,^#...] [^\^ #[^,^#...] [^\^ [...]]]^)^
  35.  
  36. Examples:       . ^matrix mymat = (1,2\3,4)^
  37.         . ^matrix myvec = (1.7, 2.93, -5, 3)^
  38.         . ^matrix mycol = (1.7\ 2.93\ -5\ 3)^
  39.  
  40.  
  41. 2.  Obtaining copies of system matrices (see ^[R] matrix get^)
  42. ------------------------------------------------------------
  43.  
  44.     ^mat^rix A ^= get(^systemname^)^
  45.  
  46. where systemname is
  47.  
  48.     ^_b^     coefficients after estimation
  49.     ^VCE^    covariance matrix of estimators after estimation
  50.     ^Rr^     constraint matrix after @test@
  51.     ^Cns^    constraint matrix after estimation 
  52.     ^Ld^     factor loadings after @factor@
  53.     ^Ev^     eigenvalues after @factor@
  54.     ^Psi^    uniquenesses after @factor@
  55.     ^Co^     correlation matrix after @factor@
  56.     ^SD^     standard deviations after @factor@
  57.     ^Mean^   means after @factor@
  58.  
  59. Examples:       . ^matrix coefs = get(_b)^
  60.         . ^matrix V = get(VCE)^
  61.  
  62.  
  63. 3.  Accumulating cross-product matrices (see ^[R] matrix accum^)
  64. --------------------------------------------------------------
  65.  
  66.     ^mat^rix ^ac^cum A ^=^ varlist [weight] [^if^ exp] [^in^ range] 
  67.             [^, d^eviations ^m^eans^(^M^) noc^onstant ]
  68.  
  69.     ^mat^rix ^glsa^ccum A ^=^ varlist [weight] [^if^ exp] [^in^ range]^,^
  70.             ^gr^oup^(^groupvar^) gl^smat^(^{W|stringvar}^) r^ow^(^rowvar^)^
  71.             [^noc^onstant]
  72.  
  73.     ^mat^rix ^veca^ccum A ^=^ varlist [weight] [^if^ exp] [^in^ range] [^, noc^onstant]
  74.  
  75.  
  76. Examples:       . ^matrix accum XpX = price weight mpg^
  77.  
  78.         (see ^[R] matrix accum^ for examples of ^glsaccum^ and ^vecaccum^)
  79.  
  80.  
  81. 4.  Matrix operators (see ^[R] matrix define^)
  82. --------------------------------------------
  83.  
  84.     ^mat^rix A ^=^ B                         (assignment)
  85.     ^mat^rix A ^=^ B^'^                        (transposition)
  86.  
  87.     ^mat^rix A ^=^ B ^+^ C                     (addition)
  88.     ^mat^rix A ^=^ B ^-^ C                     (subtraction)
  89.     ^mat^rix A ^=^ B[^'^] ^*^ C[^'^]               (multiplication)
  90.     ^mat^rix A ^=^ B ^#^ C                     (Kronecker product)
  91.  
  92.     ^mat^rix A ^=^ B ^,^ C                     (join rows)
  93.     ^mat^rix A ^=^ B ^\^ C                     (join columns)
  94.  
  95. Examples:       . ^matrix b = XpXinv * Xpy^
  96.         . ^matrix big = big , newcol^
  97.         . ^matrix big = big \ newrow^
  98.  
  99.  
  100. 5.  Matrix functions (see ^[R] matrix define^)
  101. --------------------------------------------
  102.  
  103.     ^mat^rix A ^= I(^#^)^                    (identity matrix)
  104.     ^mat^rix A ^= J(^#^,^#^,^#^)^                (r x c matrix containing z)
  105.  
  106.     ^mat^rix A ^= cholesky(^B^)^             (Cholesky decomposition)
  107.     ^mat^rix A ^= syminv(^B^)^               (inverse of symmetric matrix)
  108.     ^mat^rix A ^= inv(^B^)^                  (inverse of general matrix)
  109.     ^mat^rix A ^= sweep(^B^,^#^)^              (sweep operator)
  110.  
  111.     ^mat^rix A ^= corr(^B^)^                 (correlation from covariance)
  112.  
  113.     ^mat^rix A ^= diag(^B^)^                 (extract diagonal into vector)
  114.     ^mat^rix A ^= vecdiag(^B^)^              (make diagonal matrix from
  115.                                                  vector)
  116.  
  117. Examples:       . ^matrix id3 = I(3)^
  118.         . ^matrix zeros = J(2,3,0)^
  119.         . ^matrix XpXinv = syminv(XpX)^
  120.  
  121.  
  122. 6. Eigenvalues and eigenvectors of symmetric matrices (see ^[R] matrix symeigen^)
  123. -------------------------------------------------------------------------------
  124.  
  125. Given n x n, symmetric matrix A, 
  126.  
  127.     ^mat^rix ^syme^igen X V ^=^ A
  128.  
  129. returns the eigenvectors in the columns of X: n x n and the corresponding 
  130. eigenvalues in V: 1 x n.    The eigenvalues are sorted from largest to 
  131. smallest:  V[1,1] contains the largest eigenvector and X[.,1] its corresponding
  132. eigenvector; V[1,2] contains the second largest eigenvector and X[.,2] its
  133. corresponding eigenvector, and so on.
  134.  
  135.  
  136. 7.  Singular value decomposition (see ^[R] matrix svd^)
  137. -----------------------------------------------------
  138.  
  139. Given m x n matrix A, m>=n, 
  140.  
  141.     ^mat^rix ^svd^ U W V ^=^ A
  142.  
  143. returns U: m x n, W: 1 x n, and V: n x n such that:
  144.  
  145.     A = U diag(W) V'
  146.  
  147. In addition, U is column orthogonal, the elements of W are positive or zero,
  148. and V'V=I.
  149.  
  150.  
  151. 8.  Matrix functions returning scalars (see ^[R] matrix^)
  152. -------------------------------------------------------
  153.  
  154. The following may be used anyplace an exp is allowed:
  155.  
  156.     ^trace(^A^)^
  157.     ^rowsof(^A^)^
  158.     ^colsof(^A^)^
  159.     ^roweq(^A^,^string^)^
  160.     ^coleq(^A^,^string^)^
  161.     ^det(^A^)^
  162.     ^A[^exp^,^exp^]^      or    ^el(^{A|string}^,^exp^,^exp^)^
  163.     ^matrix(^A^)^
  164.  
  165. Examples:    . ^scalar a = det(A)^
  166.         . ^gen value = A[famrel,2]^
  167.  
  168.  
  169. 9.  Macro extended functions regarding matrices (see ^[R] matrix^)
  170. ----------------------------------------------------------------
  171.  
  172. The following extended functions are allowed with ^local^ and ^global^:
  173.  
  174.     ^: rownames(^A^)^
  175.     ^: colnames(^A^)^
  176.     ^: roweq(^A^)^
  177.     ^: coleq(^A^)^
  178.  
  179. Example:        . local names : rownames(mymat)
  180.  
  181.  
  182. 10.  Submatrix extraction (see ^[R] matrix define^)
  183. -------------------------------------------------
  184.  
  185.     ^mat^rix A ^=^ B^[^<range>^,^<range>^]^
  186.  
  187. where <range> is
  188.  
  189.         #           "name"
  190.         #^..^#        "name"^..^"name"
  191.         #^...^        "name"^...^
  192.                 "eqname^:^"
  193.  
  194. Examples:       . ^matrix sub = master[2..4, 3..7]^
  195.         . ^matrix sub = master["price".."weight", 3..7]^
  196.         . ^matrix X = Z[2..., 2...]^
  197.         . ^matrix eq1 = Z["eq1:", 2...]^
  198.  
  199.  
  200. 11.  Submatrix placement (see ^[R] matrix substitute^)
  201. ----------------------------------------------------
  202.  
  203.     ^mat^rix ^sub^stitute A[#,#] = B
  204.  
  205. Example:        . ^matrix A[2,2] = submat^
  206.  
  207.  
  208. 12.  Generating scores from coefficient vectors (see ^[R] matrix score^)
  209. ----------------------------------------------------------------------
  210.  
  211.     ^mat^rix ^sco^re [type] newvar ^=^ B [^if^ exp] [^in^ range]
  212.  
  213. where B is 1 x n or n x 1.
  214.  
  215. Example:        . matrix score index = coefs
  216.  
  217.  
  218. 13.  Setting row and column names (see ^[R] matrix rowname^)
  219. ----------------------------------------------------------
  220.  
  221.     ^mat^rix ^rown^ames A ^=^ name [name [...]]
  222.     ^mat^rix ^coln^ames A ^=^ name [name [...]]
  223.  
  224.     ^mat^rix ^rowe^q    A ^=^ name [name [...]]
  225.     ^mat^rix ^cole^q    A ^=^ name [name [...]]
  226.  
  227. where name is 
  228.     (1) a simple name 
  229.     (2) a colon followed by a simple name
  230.      (3) an equation name followed by a colon
  231.     (4) an equation name, a colon, and a simple name
  232.  
  233. (1) is interpreted as a subname by ^rownames^ and ^colnames^ and as an equation
  234. name by ^roweq^ and ^coleq^.
  235.  
  236. Example:        . ^matrix rownames A = price weight mpg^
  237.  
  238.  
  239. 14.  Posting and redisplaying estimation results (see ^[R] matrix post^)
  240. ----------------------------------------------------------------------
  241.  
  242.     ^mat^rix ^post^ b V [C] [^, dep^name^(^name^) o^bs^(^#^) d^of^(^#^)^]
  243.  
  244.     ^mat^rix ^mlou^t [^, ef^orm^(^string^) f^irst ^l^evel^(^#^)^]
  245.     
  246. See ^[R] matrix post^ for examples of these commands. 
  247.  
  248.  
  249. 15.  Constraint processing (see ^[R] matrix constraint^)
  250. ------------------------------------------------------
  251.  
  252.     ^mat^rix ^makeCns^ [clist]
  253.  
  254.     ^mat^rix ^dispCns^
  255.  
  256.     ^matcproc^ T a C
  257.  
  258. See ^[R] matrix constraint^ for examples of these commands. 
  259.     
  260.  
  261. 16.  Matrix utilities (see ^[R] matrix utility^)
  262. ----------------------------------------------
  263.  
  264.     ^mat^rix ^d^ir
  265.  
  266.     ^mat^rix ^l^ist A [^, nob^lank ^noha^lf ^noh^eader ^non^ames ^f^ormat^(^%fmt^)^
  267.              ^t^itle^(^string^)^ ]
  268.  
  269.     ^mat^rix ^drop^ { ^_all^ | A [B [...]] }
  270.  
  271. Examples:       . ^matrix list mymat^
  272.         . ^mat drop mymat^
  273.  
  274.  
  275. Also see
  276. --------
  277.  
  278.  Manual:  ^[R] matrix^
  279. On-line:  help for @mkmat@, @ml@
  280.